class Solution(object):
    def ambiguousCoordinates(self, s):
        """
        :type s: str
        :rtype: List[str]
        """
        s = s[1:-1]
        n = len(s)

        def judge(c):
            if '.' in c:
                s_split = c.split('.')
                if len(s_split[0]) == 1:
                    left_flag = True
                else:
                    if s_split[0][0] != '0':
                        left_flag = True
                    else:
                        left_flag = False
                if s_split[1][-1] != '0':
                    right_flag = True
                else:
                    right_flag = False
                return left_flag and right_flag
            else:
                if len(c) == 1:
                    return True
                if c[0] != '0':
                    return True
                else:
                    return False
        out = []
        for m in range(1, n):
            left = s[:m]
            right = s[m:n]
            for t in range(len(left)):
                if t == 0:
                    left_num = left
                else:
                    left_num = left[:t] + '.' + left[t:]
                if judge(left_num):
                    for p in range(len(right)):
                        if p == 0:
                            right_num = right
                        else:
                            right_num = right[:p] + '.' + right[p:]
                        if judge(right_num):
                            out.append('({}, {})'.format(left_num, right_num))
        return out



data = Solution()
s = "(0123)"
print(data.ambiguousCoordinates(s))
